package com.situ.mall.order.controller;

import com.situ.mall.base.entity.Banner;
import com.situ.mall.base.service.IBannerService;
import com.situ.mall.base.service.ICategoryService;
import com.situ.mall.base.util.URLUtil;
import com.situ.mall.base.vo.CategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * ClassName: IndexController
 * Package: com.situ.mall.order.controller
 * Description:
 *
 * @Author Darling_达
 * @Create 2023-03-21 21:26
 * @Version 1.0
 */

@Controller
@RequestMapping("/")
public class IndexController {

    @Autowired
    private ICategoryService categoryService;

    @Autowired
    private IBannerService bannerService;


    @GetMapping("/a")
    public String index() {
        return "order";
    }


    @GetMapping
    public String index(Model m1, Model m2) {
        // 返回页面前带数据
        // 分类展示
        List<CategoryVO> categories = categoryService.indexList();
        m1.addAttribute("categories", categories);
        // 轮播展示
        List<Banner> bannerList = bannerService.getList();
        m2.addAttribute("bannerList", bannerList);
        return URLUtil.INDEX_HTML;
    }




}
